package com.base.home.adapter;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import com.base.commonlib.recy.BaseHolderType;
import com.base.commonlib.recy.BasicRecyViewHolder;
import com.base.home.HomeConfig;
import com.base.home.R;
import com.base.home.bean.ConcertSelectEntity;

import java.util.List;
/**
 * 在此写用途
 *
 * @version V1.0 <描述当前版本功能>
 *          Created by admin on 2018/5/22.
 * @FileName: com.zhongyue.mdchengguan.ui.main.adapter.CategoryViewHolder.java
 * Author weikailiang
 * @date: 2018-05-22 14:22
 */
public class CateViewHolder extends BaseHolderType<List<ConcertSelectEntity.FunctionsBean>,CateViewHolder.categoryViewHolder> {

    @Override
    public int getType(List<ConcertSelectEntity.FunctionsBean> titleBean) {
        return HomeConfig.TYPE_CATE;
}

    @Override
    public void bindDataToHolder(final categoryViewHolder categoryViewHolder, List<ConcertSelectEntity.FunctionsBean> titleBean, int postion) {

        categoryViewHolder.mAdapter.refreshDatas(titleBean);
        categoryViewHolder.mAdapter.setItemClickListener(new BasicRecyViewHolder.OnItemClickListener() {
            @Override
            public void OnItemClick(final View v, int adapterPosition) {


            }
        });
    }



    @Override
    public categoryViewHolder buildHolder(ViewGroup parent) {
        return new categoryViewHolder(View.inflate(parent.getContext(), R.layout.main_fragment_item_category, null));
    }



    public static class categoryViewHolder extends BasicRecyViewHolder {
        private RecyclerView mRecyclerView;
        private com.base.home.adapter.CustomDivider mCustomDivider;
        CategoryAdapter mAdapter;
        public categoryViewHolder(View itemView) {
            this(itemView, null, null);
            mRecyclerView =  itemView.findViewById(R.id.recycle);
            if (mAdapter == null){
                mAdapter = new CategoryAdapter(R.layout.main_fragment_category_item);
                mRecyclerView.setAdapter(mAdapter);
            }
            mCustomDivider = new com.base.home.adapter.CustomDivider(itemView.getContext());
            mRecyclerView.addItemDecoration(mCustomDivider);
            GridLayoutManager manager = new GridLayoutManager(itemView.getContext(),4);
            mRecyclerView.setLayoutManager(manager);
            mRecyclerView.setNestedScrollingEnabled(false);
        }
        public categoryViewHolder(View itemView, OnItemClickListener clickListener, OnItemLongClickListener longClickListener) {
            super(itemView, clickListener, longClickListener);
        }
    }
}
